/**
 * 路由鉴权
 */
import React, { PureComponent } from 'react';
import { Route, Redirect, withRouter } from 'react-router-dom';

const RouteComponent = props => {
  const { route, children, location } = props;
  if (!route.auth) {
    return <Route location={location} render={() => children} />;
  }
  return <Redirect to={{ pathname: '/login', state: { from: location } }} />;
};
class RouteAuth extends PureComponent {
  render() {
    return <RouteComponent {...this.props} />;
  }
}
export default withRouter(RouteAuth);
